import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('D:\\code\\rlearn\\stock_399344_var_model_data_v2.csv')
data['date'] = data['date'].astype('datetime64[ns]')
symbols = set(data['symbol'])
### 数据处理

data = data.dropna(axis=0, how='any')

sns.set()
sns.set_style('ticks')
sns.set_context('paper')
i =0
for symbol in symbols:
    f = plt.figure()
    f.add_subplot(3, 1, 1)
    plt.title(symbol)
    mdata = data[data['symbol'] == symbol]
    total = mdata.shape[0]
    sns.lineplot(data=mdata, x='date', y='close')
    day = pd.Series([mdata.iloc[5].at['date'], mdata.iloc[80].at['date'], mdata.iloc[100].at['date'], mdata.iloc[200].at['date']])
    price = pd.Series([mdata.iloc[5].at['close'], mdata.iloc[80].at['close'], mdata.iloc[100].at['close'], mdata.iloc[200].at['close']])
    action = pd.Series(['buy', 'sell', 'buy', 'sell'])
    sns.scatterplot(day, price, hue=action, palette="Set2")
    f.add_subplot(3, 1, 2)
    plt.title("var_ma")
    sns.lineplot(data=[mdata['close_var_ma_fib_m1'], mdata['close_var_f_ma_fib_m1'], mdata["close_var_l_ma_fib_m1"],mdata['turnover_ma_fib_m1']])
    f.add_subplot(3, 1, 3)
    plt.title("var_ma_upd")
    sns.lineplot(data=[mdata['var_sub_close_ma_rate5'], mdata['var_sub_close_ma_rate10']])
    # plt.savefig("D:\\code\\rlearn\\picture1\\" + symbol + ".png")
    plt.show()
    i = i + 1
    if (i > 5):
        break

